{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<link rel="stylesheet" type="text/css" href="/Public/Css/front/front_css/my_wallet.css">
<style type="text/css">
	body{
		background-color: #f3f3f3;
	}
</style>
{/block}
{block name="content"}

<div class="title">
	
	<div class="go_back"></div>
	<p><strong>提现</strong></p>
</div>

<div class="subtitle">
	提现账户
</div>
	<a href="/FrontUserCenter/set_alipay" class="native_go">
	 <div class="set_account" data-user_alipay_id="{$user_info.user_alipay_id}">
		<div class="account_icon"></div>
		<h1>支付宝账户</h1>
		<h2>{if !$user_info.user_alipay_id}请先设置支付宝账户{else}{$user_info.alipay_account}{/if}</h2>
		<i class="icon_forward" style="position:absolute;top:1.8rem;right:3.2%;"></i>
	</div>
	</a>

<div class="withdraw_num">
	<div class="money">
		<h1>提现金额</h1>
		<h2>￥</h2><input type="number" class="input_money" id="input_money">
	</div>

		<span class="p1">可用余额</span>
		<span class="p2">￥</span><span class="p3" >{$user_info.left_money}</span>
		<span class="all_in">全部提现</span>

</div> 

<button class="submit_gery">确认提现</button>

<div class="veri_sent">
	<span class="tanchuang_success"></span>
	<span class="w">验证码已发送</span>
</div>

<!--验证码错误弹框-->
<div class="veri_wrong">
	<span class="tanchuang_defeat"></span>
	<span class="w">验证码错误</span>
</div>
{/block}
{block name="js"}
{literal}
<script type="text/javascript">

	var is_click = false ;
	$('.withdraw_num').on('click','.all_in',function(){
		var allmoney = $('.p3').text();
		console.log(allmoney);
		var input_money = document.getElementById("input_money");
		input_money.value=allmoney;
		$('.submit_gery').addClass('orange');
	});

	$('.input_money').bind('input propertychange',function(){
	
		$('.submit_gery').addClass('orange');
		var number = $('.input_money').val();
		var num =parseInt(number);
		var money = $('.p3').text();
		var mon = parseInt(money);
		var length = number.length;
		console.log(number.length);
		console.log(num);
		console.log(mon);
		if(length ==0){
			$('.submit_gery').removeClass('orange');
		}
		if(num>mon){
			var input_money = document.getElementById("input_money");
			input_money.value=mon;
		}
	});


	$('.submit_gery').on('click',function () {
		if(is_click == true) return
		is_click = true
		var user_alipay_id  = $('.set_account').attr('data-user_alipay_id');
		var money = $('#input_money').val();

		$.ajax({
			type:'post',
			url:'/FrontUserCenter/withdraw',
			data:{user_alipay_id:user_alipay_id,money:money},
			success:function (data) {
					if(data.code == 1){
						//提现成功弹窗 提示是 data.msg,并刷新页面
						$('.veri_sent').find('.w').html(data.msg);
						$('.veri_sent').fadeIn(1500);
						$('.veri_sent').fadeOut(1500);
						setTimeout(function(){
							location.reload();	
						}, 2000);
						
					}else{
						//提现失败弹窗 提示是 data.msg
						$('.veri_wrong').find('.w').html(data.msg);
						$('.veri_wrong').fadeIn(1500);
						$('.veri_wrong').fadeOut(1500);
					}
				is_click = false
			}
		})



	})


</script>
{/literal}
{/block}
